package io.renren.modules.lucky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.validator.Assert;
import io.renren.modules.lucky.dao.AppSysLogoDao;
import io.renren.modules.lucky.entity.AppSysLogoEntity;
import io.renren.modules.lucky.service.AppSysLogoService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("appSysLogoService")
public class AppSysLogoServiceImpl extends ServiceImpl<AppSysLogoDao, AppSysLogoEntity> implements AppSysLogoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AppSysLogoEntity> page = this.page(
                new Query<AppSysLogoEntity>().getPage(params), new QueryWrapper<AppSysLogoEntity>()
        );
        return new PageUtils(page);
    }

    public List<AppSysLogoEntity> getSysLogoByType(String logoType) {
        List<AppSysLogoEntity> list = baseMapper.selectList(new QueryWrapper<AppSysLogoEntity>().eq("logo_type", logoType)
                .eq("logo_flag", 1));
        Assert.isNull(list, "广告为空");
        return list;
    }

}